<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['ischecklogin']=cfc('core')->checklogin('','',true);
	$return['post']=array('id'=>0);
    $return['list']=array();
	$return['params']['status']=10;
	exi($return);
}
/*******op*******/
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'pid >'=>0,'orderid >'=>0,'mid'=>$_SESSION['uid'],'fromuser'=>-1);
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$list=pdo_getslice('jy_merch_game_fromuser',$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	if($list){
		$allitemgame=$this->allitemgame;
		foreach($list as &$item){
			$item['member']=cfc('core')->member_show($item['mid']);
			$item['info']=pdo_get('jy_merch_game_item',array('id'=>$item['pid'],'uniacid'=>$_SESSION['uniacid']),array('title','goods','onlinetime','gamename'));
			$item['merch']=pdo_get('jy_merch_user',array('id'=>$item['merchid'],'uniacid'=>$_SESSION['uniacid']),array('id','merchname','logo','pcd','address'));
			$item['merch']['pcd']=json_decode($item['merch']['pcd'],true);
			if($item['info']['onlinetime']>time()){
				$item['status']=1;
				$item['statustitle']='待分享';
			}else{
				$item['status']=0;
				$item['statustitle']='已结束';
			}
			$item['goods']=json_decode($item['info']['goods'],true);
			$item['totalprice']=0;
			foreach($item['goods'] as $gv){
				$item['totalprice'] +=$gv['price'];
			}
			$item['totalprice']=price($item['totalprice']);
			$item['typetitle']=$allitemgame[$item['info']['gamename']]['title'];
			$item['createtime']=date('Y-m-d H:i:s', $item['createtime']);
			$item['onlinetime']=date('Y-m-d H:i:s',$item['info']['onlinetime']);
			$item['sn']=pdo_getcolumn('jy_merch_game_order',array('id'=>$item['orderid'],'uniacid'=>$_SESSION['uniacid']),'ordersn');
			$item['teamnum']=$item['teamnum']?:2;
			$item['lastnum']=$item['teamnum']-$item['isteamnum'];
			$item['percent']=$item['lastnum']/$item['teamnum'];
		}
	}
	$return['list']=$list;
	exi($return);
}